{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\vgonz\Dropbox\Pitt\OneDrive for Business\Dissertation - Vale\Paper 2 - Political-Economic Polarization\Replication\Log\4_4_Figures_Appendix_CMP.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}29 Aug 2024, 15:45:24

{com}. do "C:\Users\vgonz\Dropbox\Pitt\OneDrive for Business\Dissertation - Vale\Paper 2 - Political-Economic Polarization\Replication\Do\4_4_Figures_Appendix_CMP.do"
{txt}
{com}. *****************************************************************************
. *                                 Figure Context with CMP                                               *
. *                                                                                                                                                       *                       
. * Author:                       Valentina Gonzalez Rostani                                                      *
. * Contact:                      mag384@pitt.edu                                                                 *
. * Date:                         August 9 2024                                                                                   *
. * Version:                      Stata 17                                                                                                *                                                                          
. *                                                                                                                                                       *
. *****************************************************************************
. /*
> This do-file:
> - Creates Figure A5 using data from ISSP. 
> 
> Input:
> - Data\CMP\MPDataset_MPDS2020a_stata14.dta
> 
> Output:
> -  Figure A5: Number of Nationalist Parties in Elections [Figures\Nationalist.pdf]
> 
> */
. 
. *Defining Directory
. cd "C:\Users\vgonz\Dropbox\Pitt\OneDrive for Business\Dissertation - Vale\Paper 2 - Political-Economic Polarization\Replication"
{res}C:\Users\vgonz\Dropbox\Pitt\OneDrive for Business\Dissertation - Vale\Paper 2 - Political-Economic Polarization\Replication
{txt}
{com}. 
. *Calling the data
. use "Data\CMP\MPDataset_MPDS2020a_stata14.dta", clear 
{txt}(Manifesto Project Dataset Version 2020a. Please type "notes" for more details)

{com}. 
. *******************************************************************************
. * Preparing variables
. *******************************************************************************
. {c -(}
. gen year = year(edate) 
. 
. keep if countryname=="Australia" |  countryname=="Canada" |  countryname=="Greece" |  countryname=="New Zealand" |  countryname=="Portugal" |  countryname=="Spain" |  countryname=="United Kingdom" |  countryname=="United States" |  countryname=="France" |  countryname=="Norway" | countryname=="Austria" | countryname=="Belgium" | countryname=="Denmark" | countryname=="Estonia" | countryname=="Finland" | countryname=="Hungary" | countryname=="Germany" | countryname=="Iceland"  | countryname=="Ireland"  | countryname=="Italy"  | countryname=="Netherlands"  | countryname=="Norway" | countryname=="Slovakia" | countryname=="Slovenia" | countryname=="Sweden" | countryname=="Switzerland"
{txt}(1,682 observations deleted)
{com}. 
. gen radright=1 if parfam==70
{txt}(2,679 missing values generated)
{com}. replace radright=0 if parfam>70 | parfam<70
{txt}(2,679 real changes made)
{com}. {c )-}
{txt}
{com}. 
. *******************************************************************************
. * Graphs
. *******************************************************************************
. * Graph style
. {c -(}
. grstyle clear
. set scheme s2color
. grstyle init
{res}{com}. grstyle set plain, box
. grstyle color background white
. grstyle set color dknavy
{res}{com}. grstyle yesno draw_major_hgrid yes
. grstyle yesno draw_major_ygrid yes
. grstyle color major_grid gs8
. grstyle linepattern major_grid dot
. grstyle color ci_area gs12%50
.  graph set window fontface "Georgia"
. {c )-}
{txt}
{com}. // Figure A5: Number of Nationalist Parties in Elections
. {c -(}
. sort year  // Sort the dataset by year
. collapse (sum) radright, by(year)  // Collapse the data by summing the 'radright' variable for each year
{res}{com}. tsset year  // Declare the dataset to be time-series data with 'year' as the time variable
{res}
{p 0 15 2}{txt:Time variable: }{res:year}{txt:, }{res:{bind:1920}}{txt: to }{res:{bind:2019}}{txt:, but with gaps}{p_end}
{txt}{col 9}Delta: {res}1 unit
{com}. 
. rolling, window(4) saving(rolling_dataset, replace): egen ma_radright = total(radright)  // Calculate a 4-year moving average of the 'radright' variable and save the result in 'rolling_dataset.dta'
{res}{txt}(running {bf:egen} on estimation sample)
{p 0 4 2}
(file {bf}
rolling_dataset.dta{rm}
not found)
{p_end}

Rolling replications ({res}97{txt})
{hline 4}{c +}{hline 3} 1 {hline 3}{c +}{hline 3} 2 {hline 3}{c +}{hline 3} 3 {hline 3}{c +}{hline 3} 4 {hline 3}{c +}{hline 3} 5 
..................................................    50
...............................................
{p 0 4 2}
file {bf}
rolling_dataset.dta{rm}
saved
{p_end}
{com}. 
. use "rolling_dataset.dta", clear  // Load the 'rolling_dataset.dta' file
{txt}(rolling: egen)
{com}. line mean start if start > 1969, title("Number of Nationalist Parties with 4-Yr Moving Average") xtitle("Year") ytitle("Number of Nationalist Parties")  // Create a line graph of the 4-year moving average of nationalist parties starting from 1970
{res}{com}. graph export "Figure\Nationalist.pdf", as(pdf) replace  // Export the graph to a PDF file and replace any existing file with the same name
{txt}{p 0 4 2}
file {bf}
Figure\Nationalist.pdf{rm}
saved as
PDF
format
{p_end}
{com}. 
. * Drop the .dta file
. erase "rolling_dataset.dta"  // Delete the 'rolling_dataset.dta' file from the directory
. 
. {c )-}
{txt}
{com}. 
{txt}end of do-file

{com}. exit, clear
